//
//  MJTabBarController.m
//  00-ItcastLottery
//
//  Created by apple on 14-4-14.
//  Copyright (c) 2014年 itcast. All rights reserved.
//
/**
 
 *  随机颜色
 
 */

#define RandomColor [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]



#import "ZHTabBarController.h"
#import "ZHTabBar.h"
#import "ZHTabBarButton.h"
#import "shopViewController.h"
#import "ListenListViewController.h"
#import "WatchListViewController.h"
#import "SettingViewController.h"
#import "ZHNavigationController.h"
@interface ZHTabBarController () <MJTabBarDelegate>
@end

@implementation ZHTabBarController

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
    
    self.view.backgroundColor = RandomColor;
    
    self.viewControllers = @[
                             [[ZHNavigationController alloc]initWithRootViewController:[[shopViewController alloc]init]],
                             [[ZHNavigationController alloc]initWithRootViewController:[[ListenListViewController alloc]init]],
                             [[ZHNavigationController alloc]initWithRootViewController:[[WatchListViewController alloc]init]],
                             [[ZHNavigationController alloc]initWithRootViewController:[[SettingViewController alloc]init]]                             ];
    
    // 1.移除系统自带的tabbar
    [self.tabBar removeFromSuperview];
    
    // 2.添加自己的tabbar
    ZHTabBar *myTabBar = [[ZHTabBar alloc] init];
    myTabBar.delegate = self;
    myTabBar.frame = self.tabBar.frame;
    myTabBar.backgroundColor = [UIColor greenColor];
    [self.view addSubview:myTabBar];
    
    for (int i = 0; i < self.viewControllers.count ; i++) {
        NSString *name =@"123";
        NSString *selName =@"456";
        [myTabBar addTabButtonWithName:name selName:selName];
    }
}

#pragma mark - MJTabBar的代理方法
- (void)tabBar:(ZHTabBar *)tabBar didSelectButtonFrom:(int)from to:(int)to
{
    self.selectedIndex = to;
}
@end